﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BLL
{
  public  class Delete
    {
        /// <summary>
        /// 删除模型
        /// </summary>
        public static int DeleteModel(string ID)
        {
            int id;
            try
            {
                id = Convert.ToInt32(ID);
            }
            catch
            {
                return 0;
            }
            return DAL.Delete.DeleteOne("tb_model", id);
        }
        /// <summary>
        /// 删除日志
        /// </summary>
        public static int DeleteLog(string ID)
        {
            int id;
            try
            {
                id = Convert.ToInt32(ID);
            }
            catch
            {
                return 0;
            }
            return DAL.Delete.DeleteOne("tb_log", id);
        }
      /// <summary>
      /// 批量删除日志
      /// </summary>
      /// <param name="ID"></param>
      /// <returns></returns>
        public static int DeleteSomeLog(string days)
        {
            int Para;
            try
            {
                Para = Convert.ToInt32(days);
            }
            catch
            {
                return 0;
            }
            return DAL.Delete.DeleteSome("tb_log",Para);
        }
        /// <summary>
        /// 删除用户
        /// </summary>
        public static int DeleteUser(string ID)
        {
            int id;
            try
            {
                id = Convert.ToInt32(ID);
            }
            catch
            {
                return 0;
            }
            return DAL.Delete.DeleteOne("tb_user", id);
        }
        /// <summary>
        /// 删除小黄侠
        /// </summary>
        public static int DeleteTeam(string ID)
        {
            int id;
            try
            {
                id = Convert.ToInt32(ID);
            }
            catch
            {
                return 0;
            }
            return DAL.Delete.DeleteOne("tb_team", id);
        }
        /// <summary>
        /// 删除小黄车
        /// </summary>
        public static int Deleteofo(string ID)
        {
            int id;
            try
            {
                id = Convert.ToInt32(ID);
            }
            catch
            {
                return 0;
            }
            return DAL.Delete.DeleteOne("tb_ofo", id);
        }
        /// <summary>
        /// 删除角色
        /// </summary>
        public static int DeleteRole(string ID)
        {
            int id;
            try
            {
                id = Convert.ToInt32(ID);
            }
            catch
            {
                return 0;
            }
            return DAL.Delete.DeleteOne("tb_role", id);
        }
        public static int DeleteColumn(string ID)
        {
            List<Models.Column> list = BLL.Find.FindSubColumn(ID);

            int id;
            try
            {
                id = Convert.ToInt32(ID);
            }
            catch
            {
                return 0;
            }

            if (list.Count == 0)
            {
                return DAL.Delete.DeleteOne("tb_column", id);
            }

            for (int i = 0; i < list.Count; i++)
            {
                DeleteColumn(list[i].ID.ToString());
            }

            return DAL.Delete.DeleteOne("tb_column", id);
        }
        /// <summary>
        /// 删除文章模型相应内容
        /// /// </summary>
        public static int DeleteArticle(string ID)
        {
            int id;
            try
            {
                id = Convert.ToInt32(ID);
            }
            catch
            {
                return 0;
            }
            return DAL.Delete.DeleteOne("tb_content_article", id);
        }
        /// <summary>
        /// 删除滑动图片模型相应内容
        /// /// </summary>
        public static int DeleteSlider(string ID)
        {
            int id;
            try
            {
                id = Convert.ToInt32(ID);
            }
            catch
            {
                return 0;
            }
            return DAL.Delete.DeleteOne("tb_content_slider", id);
        }
        /// <summary>
        /// 删除链接模型相应内容
        /// /// </summary>
        public static int DeleteLink(string ID)
        {
            int id;
            try
            {
                id = Convert.ToInt32(ID);
            }
            catch
            {
                return 0;
            }
            return DAL.Delete.DeleteOne("tb_content_link", id);
        }
        /// <summary>
        /// 删除办公文件模型相应内容
        /// /// </summary>
        public static int DeleteOfficeFile(string ID)
        {
            int id;
            try
            {
                id = Convert.ToInt32(ID);
            }
            catch
            {
                return 0;
            }
            return DAL.Delete.DeleteOne("tb_content_officefile", id);
        }
    }
}
